package com.loong.web.gp4j.encrypt.util;

import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

/**
 * 图标处理类
 */
public class Icons {

	/**
	 * 获取图标
	 * 
	 * @param path 路径
	 * @return 图标对象
	 */
	public static ImageIcon getIcon(String path) {

		return new ImageIcon(getImage(path));
	}

	/**
	 * 获取图片
	 * 
	 * @param path 路径
	 * @return 图片对象
	 */
	public static Image getImage(String path) {

		InputStream is = Object.class.getResourceAsStream("/" + path);
		Image img = null;
		try {
			img = ImageIO.read(is);
		} catch (IOException e) {
		} finally {
			if (is != null) {
				try {
					is.close();
				} catch (IOException e) {
				}
			}
		}
		return img;
	}
}
